package com.ruoyi.project.jiaqin.downstandard.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.jiaqin.downstandard.domain.DownStandard;
import com.ruoyi.project.jiaqin.downstandard.service.IDownStandardService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 羽绒标准分类Controller
 * 
 * @author admin
 * @date 2021-01-29
 */
@Controller
@RequestMapping("/jiaqin/downstandard")
public class DownStandardController extends BaseController
{
    private String prefix = "jiaqin/downstandard";

    @Autowired
    private IDownStandardService downStandardService;

    @RequiresPermissions("jiaqin:downstandard:view")
    @GetMapping()
    public String downstandard()
    {
        return prefix + "/downstandard";
    }

    /**
     * 查询羽绒标准分类列表
     */
    @RequiresPermissions("jiaqin:downstandard:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(DownStandard downStandard)
    {
        startPage();
        List<DownStandard> list = downStandardService.selectDownStandardList(downStandard);
        return getDataTable(list);
    }

    /**
     * 导出羽绒标准分类列表
     */
    @RequiresPermissions("jiaqin:downstandard:export")
    @Log(title = "羽绒标准分类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(DownStandard downStandard)
    {
        List<DownStandard> list = downStandardService.selectDownStandardList(downStandard);
        ExcelUtil<DownStandard> util = new ExcelUtil<DownStandard>(DownStandard.class);
        return util.exportExcel(list, "downstandard");
    }

    /**
     * 新增羽绒标准分类
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存羽绒标准分类
     */
    @RequiresPermissions("jiaqin:downstandard:add")
    @Log(title = "羽绒标准分类", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(DownStandard downStandard)
    {
        return toAjax(downStandardService.insertDownStandard(downStandard));
    }

    /**
     * 修改羽绒标准分类
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        DownStandard downStandard = downStandardService.selectDownStandardById(id);
        mmap.put("downStandard", downStandard);
        return prefix + "/edit";
    }

    /**
     * 修改保存羽绒标准分类
     */
    @RequiresPermissions("jiaqin:downstandard:edit")
    @Log(title = "羽绒标准分类", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(DownStandard downStandard)
    {
        return toAjax(downStandardService.updateDownStandard(downStandard));
    }

    /**
     * 删除羽绒标准分类
     */
    @RequiresPermissions("jiaqin:downstandard:remove")
    @Log(title = "羽绒标准分类", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(downStandardService.deleteDownStandardByIds(ids));
    }
}
